<?php
/**
 * 注册Action
 * Enter description here ...
 * @author nijn
 *
 */
class RegisterAction extends CAction{
	/**
	 * 模型
	 * Enter description here ...
	 * @var unknown_type
	 */
	public $modelName;
	/**
	 * 页面
	 * Enter description here ...
	 * @var unknown_type
	 */
	public $view;
	
	/**
	 * 成功跳转页
	 * Enter description here ...
	 * @var unknown_type
	 */
	public $returnUrl = array('index');
	
	public function run() {
		$c = $this->controller;
		$model = new $this->modelName('register');
		if (isset($_POST[$this->modelName])) {
			$model->attributes = $_POST[$this->modelName];
			if ($model->save()) {
				$login = new AdminLoginForm();
				$login->modelName = 'FontLoginIdentity';
				$login->username = $model->worker_name;
				$login->password = $model->worker_password;
				$login->login();
				Yii::app()->user->setFlash(FLASH::RESULT_SUCCESS, '恭喜您，注册成功！');
				$c->redirect($this->returnUrl);
			}
		}
		
		$c->render($this->view, array(
			'model' => $model,
		));
	}
}

?>